﻿using System;
using System.ComponentModel;
using DevExpress.XtraGrid.Views.Grid;

namespace Marmat.Forms
{
    public partial class DataGrid
    {

        /// <summary>
        /// 逻辑型，是否允许用户增加行。默认为True，设为False，将禁止用户增加行。
        /// </summary>
        /// <value></value>
        /// <returns></returns>
        /// <remarks></remarks>
        [Obsolete("当前属性好像没有实际场景，所以尚未实现。")]
        private bool AllowAddNew { get; set; }


        /// <summary>
        /// 逻辑型，复制表中内容的时候，是否包括列名，默认为False。
        /// </summary>
        /// <value></value>
        /// <returns></returns>
        /// <remarks></remarks>
        [DefaultValue(false)]
        [Browsable(false)]
        [Category("外观")]
        [Description("逻辑型，复制表中内容的时候，是否包括列名，默认为False。")]
        public bool AllowCopyHeader
        {
            get
            {
                return this._AllowCopyHeader;
            }

            set
            {
                this._AllowCopyHeader = value;
                this.SetValue("OptionsBehavior.CopyToClipboardWithColumnHeaders", value);
            }
        }

        private bool _AllowCopyHeader = false;

        /// <summary>
        /// 是否允许单击列标题排序。
        /// </summary>
        /// <value></value>
        /// <returns></returns>
        /// <remarks></remarks>
        [DefaultValue(true)]
        [Category("外观")]
        [Description("是否允许单击列标题排序。")]
        public bool AllowClickSort
        {
            get
            {
                return this._AllowClickSort;
            }

            set
            {
                if (this.AllowClickSort != value)
                {
                    this._AllowClickSort = value;
                    this.SetValue("OptionsCustomization.AllowClickSort", value);
                }
            }
        }

        private bool _AllowClickSort = true;

        /// <summary>
        /// 逻辑型，是否允许移动列。
        /// </summary>
        /// <value></value>
        /// <returns></returns>
        /// <remarks></remarks>
        [DefaultValue(true)]
        [Category("外观")]
        [Description("逻辑型，是否允许移动列。")]
        public bool AllowColumnMoving
        {
            get
            {
                return this._AllowColumnMoving;
            }

            set
            {
                if (this.AllowColumnMoving != value)
                {
                    this._AllowColumnMoving = value;
                    this.SetValue("AllowColumnMoving", value);
                }
            }
        }

        private bool _AllowColumnMoving = true;

        /// <summary>
        /// 是否允许通过鼠标拖动来调整列宽。
        /// </summary>
        /// <value></value>
        /// <returns></returns>
        /// <remarks></remarks>
        [DefaultValue(true)]
        [Category("外观")]
        [Description("是否允许通过鼠标拖动来调整列宽。")]
        public bool AllowColumnResizing
        {
            get
            {
                return this._AllowColumnResizing;
            }

            set
            {
                if (this.AllowColumnResizing != value)
                {
                    this._AllowColumnResizing = value;
                    this.SetValue("AllowColumnResizing", value);
                }
            }
        }

        private bool _AllowColumnResizing = true;

        /// <summary>
        /// 获取或设置当前表格的焦点列。
        /// </summary>
        /// <value></value>
        /// <returns></returns>
        /// <remarks></remarks>
        [Browsable(false)]
        public Views.DataGrid.Column FocusedColumn
        {
            get
            {
                Views.DataGrid.Column result = null;
                var column = Help.get_FocusedColumn(this.BaseControl.MainView);
                if (column is object)
                    result = (Views.DataGrid.Column)column.Tag;
                return result;
            }
        }

        /// <summary>
        /// 获取或设置是否显示新增行
        /// </summary>
        /// <value></value>
        /// <returns></returns>
        /// <remarks></remarks>
        [DefaultValue(false)]
        [Category("行为")]
        [Description("获取或设置是否显示新增行。")]
        public bool ShowAddNew
        {
            get
            {
                return this.m_ShowAddNew;
            }

            set
            {
                if (this.m_ShowAddNew != value)
                {
                    this.m_ShowAddNew = value;
                    NewItemRowPosition NewItemRowPosition = this.ShowAddNew ? DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.Bottom : DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.None;
                    this.SetValue("NewItemRowPosition", NewItemRowPosition);
                }
            }
        }

        private bool m_ShowAddNew = false;

        /// <summary>
        /// 返回 BDataGrid 的列集合。
        /// </summary>
        /// <value></value>
        /// <returns></returns>
        /// <remarks></remarks>
        [EditorBrowsable(EditorBrowsableState.Always)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        [Localizable(true)]
        [NotifyParentProperty(true)]
        [Category("数据")]
        [Description("返回 BDataGrid 的列集合。")]
        public virtual new Views.DataGrid.ColumnCollection Columns
        {
            get
            {
                if (this.m_Columns is null)
                {
                    this.m_Columns = new Views.DataGrid.ColumnCollection(this, base.Columns);
                }

                return this.m_Columns;
            }
        }

        private Views.DataGrid.ColumnCollection m_Columns;
    }
}